package com.itheima.day08.myTreeSet.test5;

import java.util.Comparator;
import java.util.Scanner;
import java.util.TreeSet;

public class Test1{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        TreeSet<String> treeSet = new TreeSet<>(new Comparator<String>() {
            @Override
            public int compare(String s1, String s2) {
                int result = s1.length() - s2.length();
                result =  result == 0 ? s1.compareTo(s2) : result;
                return result;
            }
        });

        for (int i = 0; i < 5; i++) {
            System.out.println("请输入要传入的字符串");
            String str = sc.nextLine();
            str.trim();
            treeSet.add(str);
        }
        for (String s : treeSet) {
            System.out.print(s + " ");
        }

    }


}
